/**
 * 系统平台
 * moonvip_admin
 * com.tz.web.dayprice
 * DaypriceController.java
 * 创建人:小胡
 * 时间：2017年02月03日 09:03:56
 *
 */
package com.tz.web.service;

import com.tz.auth.AuthPassport;
import com.tz.bean.Dayprice;
import com.tz.bean.TzParams;
import com.tz.service.dayprice.IDaypriceService;
import com.tz.service.dictinfo.IDictInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 今日金价管理web
 * DaypriceController
 * 创建人:小胡
 * 时间：2017年02月03日 09:03:56
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/admin/service")
public class DaypriceController {
	
	@Resource
	private IDaypriceService daypriceService;

	@Resource
	private IDictInfoService ddictInfoService;

	/*列表查询*/
	@AuthPassport
	@RequestMapping("/dayprice/list")
	public String list(TzParams params){
		return "service/dayprice/list";
	}

    /*模板页面*/
	@RequestMapping("/dayprice/template")
	public String template(TzParams params ,Model model){
		params.setDeleteCode("001");
		model.addAttribute("datas", daypriceService.findDayprices(params));
		model.addAttribute("itemCount", daypriceService.count(params));
		return "service/dayprice/template";
	}

	@AuthPassport
	@ResponseBody
	@RequestMapping("/dayprice/add")
	public String add(TzParams params){
		daypriceService.add();
		return "success";
	}

	@AuthPassport
	@ResponseBody
	@RequestMapping(value="/dayprice/update",method= RequestMethod.POST)
	public int update(Dayprice dayprice){
		int n =  daypriceService.update(dayprice);
		return n;
	}

	@AuthPassport
	@ResponseBody
	@RequestMapping(value="/dayprice/delete",method=RequestMethod.POST)
	public String delete(Integer id){
		daypriceService.delete(id);
		return "success";
	}


	@RequestMapping(value = "/dayprice/edit/{id}" ,method = RequestMethod.GET)
    public String edit(@PathVariable("id") Integer id , Model model){
		HashMap<String ,Object> dayprice = daypriceService.getDayprice(id);
		model.addAttribute("dayprice",dayprice);
		return "service/dayprice/edit";
	}

	/**
	 * 跳转到翻新价格修改页面
	 */
	@AuthPassport
	@RequestMapping(value = "/changeRefurbishPrice")
	public String  changeRefurbishPrice(Model model){
		//获取翻新价格
		Map<String , Object> refurbishPrice =   ddictInfoService.findDictInfos(43);
		model.addAttribute("refurbishPrice" , refurbishPrice);
		return "service/changeRefurbishPrice";
	}

	/**
	 * 跳转到检测价格修改页面
	 */
	@AuthPassport
	@RequestMapping(value = "/changeTestingPrice")
	public String  changeTestingPrice(Model model){
		//获取检测价格
		Map<String , Object> refurbishPrice =   ddictInfoService.findDictInfos(44);
		model.addAttribute("refurbishPrice" , refurbishPrice);
		return "service/changeTestingPrice";
	}
}
